<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>控制台</title>
<link rel="stylesheet" href="/layui/css/layui.css">
<script src="/static/js/jquery.min.js"></script>
<script src="/layui/layui.js"></script>
<style>
body{background:#f5f5f5;padding:20px;}
.stat-card{display:inline-block;width:23%;margin:0 1% 20px;background:#fff;border-radius:8px;padding:20px;box-shadow:0 2px 8px rgba(0,0,0,.06);box-sizing:border-box;}
.stat-card .num{font-size:32px;font-weight:700;margin:8px 0;color:#333;}
.stat-card .label{color:#999;font-size:14px;}
.stat-card.c1{border-top:3px solid #1e9fff;}.stat-card.c2{border-top:3px solid #16baaa;}.stat-card.c3{border-top:3px solid #ffb800;}
.stat-card.c4{border-top:3px solid #ff5722;}.stat-card.c5{border-top:3px solid #5fb878;}.stat-card.c6{border-top:3px solid #a233c6;}
.panel{background:#fff;border-radius:8px;margin-bottom:20px;box-shadow:0 2px 8px rgba(0,0,0,.06);}
.panel .panel-title{padding:15px 20px;border-bottom:1px solid #eee;font-size:16px;font-weight:600;color:#333;}
.panel .panel-body{padding:20px;}.layui-table{margin:0;}
</style>
</head>
<body>
<div style="display:flex;flex-wrap:wrap;">
    <div class="stat-card c1"><div class="label">用户总数</div><div class="num"><?= $userCount ?></div></div>
    <div class="stat-card c2"><div class="label">应用总数</div><div class="num"><?= $appCount ?></div></div>
    <div class="stat-card c3"><div class="label">今日API调用</div><div class="num"><?= $todayCalls ?></div></div>
    <div class="stat-card c4"><div class="label">今日收入(元)</div><div class="num"><?= number_format($todayIncome, 2) ?></div></div>
    <div class="stat-card c5"><div class="label">通道数量</div><div class="num"><?= $channelCount ?></div></div>
    <div class="stat-card c6"><div class="label">套餐数量</div><div class="num"><?= $packageCount ?></div></div>
</div>
<div class="panel"><div class="panel-title">最近订单</div><div class="panel-body">
    <table class="layui-table" lay-size="sm">
        <thead><tr><th>订单号</th><th>套餐名称</th><th>金额</th><th>支付状态</th><th>购买时间</th></tr></thead>
        <tbody><?php foreach ($recentOrders as $order): ?><tr><td><?= $order['order_no'] ?></td><td><?= $order['package_name'] ?></td><td>¥<?= number_format($order['amount'],2) ?></td><td><?= $order['pay_status']==1?'<span style="color:green">已支付</span>':($order['pay_status']==2?'<span style="color:red">已失效</span>':'<span style="color:orange">未支付</span>') ?></td><td><?= $order['create_time'] ?></td></tr><?php endforeach; ?>
        <?php if(empty($recentOrders)): ?><tr><td colspan="5" style="text-align:center;color:#999;">暂无数据</td></tr><?php endif; ?></tbody>
    </table>
</div></div>
<div class="panel"><div class="panel-title">最近操作日志</div><div class="panel-body">
    <table class="layui-table" lay-size="sm">
        <thead><tr><th>操作人</th><th>操作</th><th>IP</th><th>时间</th></tr></thead>
        <tbody><?php foreach ($recentLogs as $log): ?><tr><td><?= $log['admin_name'] ?></td><td><?= $log['action'] ?></td><td><?= $log['ip'] ?></td><td><?= $log['create_time'] ?></td></tr><?php endforeach; ?>
        <?php if(empty($recentLogs)): ?><tr><td colspan="4" style="text-align:center;color:#999;">暂无数据</td></tr><?php endif; ?></tbody>
    </table>
</div></div>
</body>
</html>